package top.lingkang.securityoauth2.core.utils;

import java.lang.reflect.Field;

/**
 * @author lingkang
 * Created by 2022/7/8
 */
public class PrivateAccessUtils {
    public static Object getPrivateValue(Object obj, String privateName) {
        try {
            Field field = obj.getClass().getDeclaredField(privateName);
            return field.get(obj);
        } catch (Exception e) {
        }
        return null;
    }

    public static void resetPrivateValue(Object obj,String privateName,Object newValue){
        try {
            Field field = obj.getClass().getDeclaredField(privateName);
            field.setAccessible(true);
            field.set(field,newValue);
        }catch (Exception e){}
    }
}
